<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function fu(arr = []) {
        if (arr.length === 0) {
          return 0
        }
        if (arr.length === 1) {
          return arr[0]
        }

      const aa = [arr[0],Math.max(arr[0],arr[1])]
      for(let i = 2; i <arr.length; i++) {
        aa[i] = Math.max(arr[i] + aa[i - 2],aa[i-1])
      }
      console.log(aa);
      }
      fu([5,3,6,8,30])
    </script>
  </body>
</html>
